#ifndef EGG_MATERIAL_H
#define EGG_MATERIAL_H

#include "Shader.h"
#include "Texture.h"
#include "StateCache.h"
#include "FrameEvent.h"

namespace egg{

    class Material;
    typedef shared_ptr<Material> MaterialPtr;

    class Material{
    public:
        Material(ShaderPtr shader);
        void setColor(const vec4& rgba);
        void setOpacity(float opacity);
        void setShininess(float shininess);
        void setReflection(float reflection);
        void setRefraction(float refraction);
        void setTransparentType(TransparentType type);

        inline float getOpacity(){
            return mExt->r; 
        }
        inline float getRefraction(){
            return mExt->g;
        }
        inline float getReflection(){
            return mExt->b;
        }
        inline float getShininess(){
            return mColor->a;
        }
        inline const vec4& getColor(){
            return *mColor;
        }
        inline TransparentType getTransparentType(){
            return mTransparentType;
        }
        inline ShaderPtr getShader(){
            return mShader;
        }
        inline ShaderParamMap* getParamMap(){
            return &mParamMap;
        }
        inline TextureParamPtr getTextureParam(const string& name){
            return mParamMap.getTextureParam(name);
        }
        inline void setFillMode(GLenum fill){
            mFillMode=fill;
        }
        inline void setCullMode(GLenum cull){
            mCullMode=cull;
        }
        inline int getStencilMask(){
            return mStencilMask;
        }
        inline GLenum getFillMode(){
            return mFillMode;
        }
        inline GLenum getCullMode(){
            return mCullMode;
        }
    protected:
        vec4* mColor;//[color,shininess]
        vec4* mExt;//[opacity,refract,reflect]
        GLenum mFillMode;
        GLenum mCullMode;
        uint32 mStencilMask;
        TransparentType mTransparentType;
        ShaderParamMap mParamMap;
        ShaderPtr mShader;
    };

}

#endif